<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link rel="stylesheet" th:href="@{/src/css/layui.css}">
</head>
<body>
<!--<form action="/fixpwd" method="post">
    旧密码  <input th:type="text" name="oldpassword"/><br>
    新密码 <input th:type="text" name="newpassword"/><br>
<input th:type="submit" th:value="提交" class="layui-btn layui-btn-normal userAdd_btn">
</form>-->



<form  class="layui-form">
    <div class="layui-input-inline">
        <input type="password" id="oldpassword" value="" placeholder="旧密码"
               name="oldpassword"  class="layui-input search_input"><br>
        <input type="password" id="newpassword" value="" placeholder="新密码"
               name="newpassword"  class="layui-input search_input">
    </div>
   <!-- <div class="layui-input-inline">

    </div>-->
   <!-- 旧密码  <input th:type="text" name="oldpassword"/><br>
    新密码 <input th:type="text" name="newpassword"/><br>-->
    <!--<input th:type="submit" th:value="提交" class="layui-btn layui-btn-normal userAdd_btn">-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addUser">立即提交</button>
        </div>
    </div>
</form>
</body>
<script th:src="@{/src/layui.js}"></script>
<script>

    layui.use(['form','layer','jquery'],function () {
        var form = layui.form,

            $ = layui.jquery,
            layer = layui.layer;


        //添加
        form.on('submit(addUser)',function (data) {
            //console.log(data.field.emailAddress);
            var oldpassword=data.field.oldpassword;
            var  newpassword=data.field.newpassword;
            //layer.msg(emailAddres);
            $.ajax({
                url:'/fixpwd',
                type:'post',
                data:data.field,
                dataType:'json',
                success:function (res) {
                    if(res.code == 200){
                        layer.msg('修改成功',{icon:1},function () {
                            /*parent.layer.closeAll("iframe");
                            parent.location.reload();*/
                            location.href="/sys/main"
                        });
                    }else{
                        layer.msg(res.message,{icon:5});
                    }
                }
            })
            return false; //表单不提交，通过ajax的方式异步提交数据。
        })
    })





</script>
</html>